//
//  ViewController.m
//  UI_FrameAndBounds
//
//  Created by aaaaaa on 16/6/4.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#define kFrameNSLog(VIEW)  NSLog(@"VIEW frame: x : %lf , y : %lf, w : %lf, y : %lf", VIEW.frame.origin.x, VIEW.frame.origin.y, VIEW.frame.size.width, VIEW.frame.size.height)

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createsubViews];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)createsubViews{
    //创建视图1，添加到self.view上
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 300, 500)];
    view1.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:view1];
    [view1 release];
    //创建视图2，添加到视图1上
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100 , 100)];
    view2.backgroundColor = [UIColor greenColor];
    [view1 addSubview:view2];
    [view2 release];
    
    NSLog(@"view1 bounds: x : %lf , y : %lf, w : %lf, y : %lf", view1.bounds.origin.x, view1.bounds.origin.y, view1.bounds.size.width, view1.bounds.size.height);
    
    NSLog(@"view2 bounds: x : %lf , y : %lf, w : %lf, y : %lf", view2.bounds.origin.x, view2.bounds.origin.y, view2.bounds.size.width, view2.bounds.size.height);
    
    //改变view1的bounds的origin，改变了它的子视图位置
    view1.bounds = CGRectMake(50, 50, 300, 500);
    
    //改变view1的bounds的size，改变了它自身在父视图的位置，影响到了它的frame
    view1.bounds = CGRectMake(0, 0, 200, 300);
//    NSLog(@"view1 frame: x : %lf , y : %lf, w : %lf, y : %lf", view1.frame.origin.x, view1.frame.origin.y, view1.frame.size.width, view1.frame.size.height);
    kFrameNSLog(view1);
}







































@end
